package com.ruoyi.shop.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.shop.domain.pojo.AddListImage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.shop.api.domain.CheShopImage;
import com.ruoyi.shop.service.ICheShopImageService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 门店照片Controller
 * 
 * @author ruoyi
 * @date 2025-01-03
 */
@RestController
@RequestMapping("/image")
public class CheShopImageController extends BaseController
{
    @Autowired
    private ICheShopImageService cheShopImageService;

    /**
     * 查询门店照片列表
     */
    @RequiresPermissions("shop:image:list")
    @GetMapping("/list")
    public TableDataInfo list(CheShopImage cheShopImage)
    {
        startPage();
        List<CheShopImage> list = cheShopImageService.selectCheShopImageList(cheShopImage);
        return getDataTable(list);
    }

    /**
     * 导出门店照片列表
     */
    @RequiresPermissions("shop:image:export")
    @Log(title = "门店照片", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CheShopImage cheShopImage)
    {
        List<CheShopImage> list = cheShopImageService.selectCheShopImageList(cheShopImage);
        ExcelUtil<CheShopImage> util = new ExcelUtil<CheShopImage>(CheShopImage.class);
        util.exportExcel(response, list, "门店照片数据");
    }

    /**
     * 获取门店照片详细信息
     */
    @RequiresPermissions("shop:image:query")
    @GetMapping(value = "/{shopImageId}")
    public AjaxResult getInfo(@PathVariable("shopImageId") Long shopImageId)
    {
        return success(cheShopImageService.selectCheShopImageByShopImageId(shopImageId));
    }



    /**
     * 新增门店照片
     */
    @RequiresPermissions("shop:image:add")
    @Log(title = "门店照片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CheShopImage cheShopImage)
    {
        return toAjax(cheShopImageService.insertCheShopImage(cheShopImage));
    }



    @Log(title = "门店照片批量插入", businessType = BusinessType.INSERT)
    @PostMapping("/adds")
    public AjaxResult adds(@RequestBody AddListImage cheShopImage)
    {
        return toAjax(cheShopImageService.insertCheShopImages(cheShopImage));
    }

    /**
     * 修改门店照片
     */
    @RequiresPermissions("shop:image:edit")
    @Log(title = "门店照片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CheShopImage cheShopImage)
    {
        return toAjax(cheShopImageService.updateCheShopImage(cheShopImage));
    }

    /**
     * 删除门店照片
     */
    @RequiresPermissions("shop:image:remove")
    @Log(title = "门店照片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{shopImageIds}")
    public AjaxResult remove(@PathVariable Long[] shopImageIds)
    {
        return toAjax(cheShopImageService.deleteCheShopImageByShopImageIds(shopImageIds));
    }
}
